/*
 * $Id: Field.java 82 2012-12-18 14:54:52Z Denis.Skalsky@gmail.com $
 */
package com.globallogic.skalskyy.javabasic.valstaff;

/**
 * Field is a parameter of employee.
 * @author $Author: Denis.Skalsky@gmail.com $
 * @version $Revision: 82 $
 */
public class Field <T> {
	
	private T value;

	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}

	public Field() {		
	}

	public Field (T value) {
		this.setValue(value);
	}

	@Override
	public String toString() {
		if (value == null) {
			return "";
		} else {
			return value.toString();
		}
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		
		if (obj == null)
			return false;
		
		if (this.getClass() != obj.getClass())
			return false;
		
		Field<?> field = (Field<?>) obj;
		
		if (value == null) {
			if (field.value != null)
				return false;
		} else if (!value.toString().equalsIgnoreCase(field.value.toString()))
			return false;
		
		return true;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		return result;
	}	
}